package com.ohxwj.modules.sys.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ohxwj.modules.sys.entity.SysRoleXcxEntity;
import com.ohxwj.modules.sys.service.SysRoleXcxService;
import com.ohxwj.common.utils.PageUtils;
import com.ohxwj.common.utils.Query;
import com.ohxwj.common.utils.R;




/**
 * 角色小程序功能关联
 * 
 * @author xuwenjie
 * @date 2018-01-13 22:41:18
 */
@RestController
@RequestMapping("/sys/sysrolexcx")
public class SysRoleXcxController {
	@Autowired
	private SysRoleXcxService sysRoleXcxService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("sys:sysrolexcx:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<SysRoleXcxEntity> sysRoleXcxList = sysRoleXcxService.queryList(query);
		int total = sysRoleXcxService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(sysRoleXcxList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("sys:sysrolexcx:info")
	public R info(@PathVariable("id") Long id){
		SysRoleXcxEntity sysRoleXcx = sysRoleXcxService.queryObject(id);
		
		return R.ok().put("sysRoleXcx", sysRoleXcx);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("sys:sysrolexcx:save")
	public R save(@RequestBody SysRoleXcxEntity sysRoleXcx){
		sysRoleXcxService.save(sysRoleXcx);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("sys:sysrolexcx:update")
	public R update(@RequestBody SysRoleXcxEntity sysRoleXcx){
		sysRoleXcxService.update(sysRoleXcx);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("sys:sysrolexcx:delete")
	public R delete(@RequestBody Long[] ids){
		sysRoleXcxService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
